<!DOCTYPE html>
<html lang="cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>发送新消息 Message Form</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" th:href="@{/statics/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/statics/style/admin.css}" media="all">
    <link rel="stylesheet" th:href="@{/statics/wang/wangeditor.css}">
    <style type="text/css">
        .wangEditor-txt{
            height: 200px !important;/*!important是重点，因为原div是行内样式设置的高度300px*/
        }
    </style>
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-message" id="layuiadmin-form-message" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">收件人</label>
        <div class="layui-input-block">
            <select name="toId" lay-verify="required">
                <option value="">请选择收件人</option>
                <option th:each="user:${users}" th:value="${user.id}" th:text="${user.nickName + '[' + user.userName + '] '}"></option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入消息标题" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
            <textarea type="text" id="content" name="content" autocomplete="off" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="hidden" name="id" autocomplete="off" class="layui-input">
        <input type="hidden" name="fromId" autocomplete="off" class="layui-input" th:value="${session.CURRENT_USER_SESSION.id}">
        <button class="layui-btn" lay-submit lay-filter="LAY-message-add-submit" id="LAY-message-add-submit">提交</button>
    </div>
</div>

<script th:src="@{/statics/layui/layui.js}"></script>
<script>
    layui.config({
        base: '/statics/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'wangeditor'], function () {
        var $ = layui.$
            , wang = layui.wangeditor('#content')
            , form = layui.form;

        wang.config.customUpload = false;
        wang.config.uploadImgUrl = '/cms/wangEditor/local/saveImg';
        wang.config.uploadImgFileName = 'file';
        wang.config.uploadImgFns.onload = function (resultText, xhr) {
            var obj = eval('(' + resultText + ')');
            wang.command(null, 'insertHtml', '<img src="' + obj.data + '" style="max-width:100%;"/>');
        };
        wang.create();
    })
</script>
</body>
</html>